import { lazy } from "react";
import { useRoutes,Navigate } from "react-router-dom";

import {
    AppstoreOutlined,
} from '@ant-design/icons';

// import MyRouter1 from "./aa.js";

// 主界面
const MyLayout = lazy(()=>import('../components/MyLayout/MyLayout.jsx'))
const Hoc = lazy(()=>import('../api/Hoc.jsx'));
const Login = lazy(()=>import('../view/login/Login.jsx'));
const Guanli = lazy(()=>import('../view/guanli/Guanli.jsx'))

// 资产
const ZC = lazy(()=>import('../components/zichan/ZC.jsx'));
const LY = lazy(()=>import('../components/zichan/ly/LY.jsx'));
const KJ = lazy(()=>import('../components/zichan/kj/KJ.jsx'));
// 客户
const KH = lazy(()=>import('../components/kehu/KH.jsx'));
const KHGL = lazy(()=>import('../components/kehu/khgl/KHGL.jsx'));
const QYLXR = lazy(()=>import('../components/kehu/qylxr/QYLXR.jsx'));
const ZQGLY = lazy(()=>import('../components/kehu/zqgly/ZQGLY.jsx'));

// 招商
const ZS = lazy(()=>import('../components/zhaoshang/ZS.jsx'));
const KJDJ = lazy(()=>import('../components/zhaoshang/kjdj/KJDJ.jsx'));
const ZK = lazy(()=>import('../components/zhaoshang/zk/ZK.jsx'));
const ZY = lazy(()=>import('../components/zhaoshang/zy/ZY.jsx'));

//物业服务
const WYFW = lazy(()=>import('../components/wuyefuwu/WYFW.jsx'));
const ZQGL = lazy(()=>import('../components/wuyefuwu/zqgl/ZQGL.jsx'))
const ZHBX = lazy(()=>import('../components/wuyefuwu/zhbx/ZHBX.jsx'))
const BXSZ = lazy(()=>import('../components/wuyefuwu/bxsz/BXSZ.jsx'))
const GLYGG = lazy(()=>import('../components/wuyefuwu/glygg/GLYGG.jsx'))
const GLYFK = lazy(()=>import('../components/wuyefuwu/glyfk/GLYFK.jsx'))
const WYXZ = lazy(()=>import('../components/wuyefuwu/wyxz/WYXZ.jsx'))

// 普通导出,  需要使用 { routes } 引入
// 配置导航路由
export const routes = [
    // 主界面
    // {
    //     path:'/index',
    //     name:'111',
    //     element:<MyLayout/>
    // },
    // 资产
    {
        path:'zichan',
        title:'资产',
        icon:<AppstoreOutlined/>,
        element:<ZC />,
        children:[
            {
                path:'ly',
                title:'楼宇',
                element:<LY />,
            },
            {
                path:'kj',
                title:'空间',
                element:<KJ />,
            },
        ]
    },
    // 客户
    {
        path:'kehu',
        title:'客户',
        icon:<AppstoreOutlined/>,
        element:<KH />,
        children:[
            {
                path:'khgl',
                title:'客户管理',
                element:<KHGL />,
            },
            {
                path:'qylxr',
                title:'签约联系人',
                element:<QYLXR />,
            },
            {
                path:'zqgly',
                title:'租期管理员',
                element:<ZQGLY />,
            },
        ]
    },
    // 招商
    {
        path:'zhaoshang',
        title:'招商',
        icon:<AppstoreOutlined/>,
        element:<ZS />,
        children:[
            {
                path:'kjdj',
                title:'空间定价',
                element:<KJDJ />,
            },
            {
                path:'zk',
                title:'租控',
                element:<ZK />,
            },
            {
                path:'zy',
                title:'租约',
                element:<ZY />,
            },
        ]
    },
    // 物业服务
    {
        path:'wuyefuwu',
        title:'物业服务',
        icon:<AppstoreOutlined/>,
        element:<WYFW />,
        children:[
            {
                path:'zqgl',
                title:'租期管理',
                element:<ZQGL />,
            },
            {
                path:'zhbx',
                title:'租户报修',
                element:<ZHBX />,
            },
            {
                path:'bxsz',
                title:'保修设置',
                element:<BXSZ />,
            },
            {
                path:'glygg',
                title:'管理员公告',
                element:<GLYGG />,
            },
            {
                path:'glyfk',
                title:'管理员反馈',
                element:<GLYFK />,
            },
            {
                path:'wyxz',
                title:'物业须知',
                element:<WYXZ />,
            }
        ]
    },
];
//2.配置总路由
let rout = [
    {
        path:'/',
        element:<Navigate to="/home" />
    },
    {
        path:'/home',
        element:<Hoc comp={<MyLayout />} url='/login' />,
        children:[ ...routes ]
    },
    {
        path:'/login',
        element:<Login />
    },
    {
        path:'/guanli',
        element:<Guanli/>
    }
];



function MyRouter(){
    return useRoutes(rout);
};
export default MyRouter;